﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entidades;
namespace Logica.WebServices_BCR
{
    public class MailMessage
    {        

        public int files{get;set;}
        public int documentsOk { get; set; }
        public int documentsNoOk { get; set; }
        private DateTime beginTime;
       
        public MailMessage() { 
            files=0;
            documentsOk =0;
            documentsNoOk = 0;
            beginTime = DateTime.Now;
        }
             

        public String toString()
        {
            return "<html><head></head><body><html><head>"+
                "<style type='text/css'><!--.Estilo1 {font-family: Arial, Helvetica, sans-serif; font-weight: bold;}.Estilo2 {font-family: Arial, Helvetica, sans-serif}.Estilo4 {font-family: Arial, Helvetica, sans-serif; font-weight: bold; color: #CC0000; }.Estilo6 { font-family: Arial, Helvetica, sans-serif; color: #FFFFFF; font-weight: bold;}--></style>"+
                "</head><body><table width='700' border='1' cellspacing='0' cellpadding='0'><tr><td>"+
                "<table width='700' border='0' cellspacing='0' cellpadding='1'><tr height='20'>"+
                "<td colspan='5'><div align='lefth'><div align='center' class='Estilo1'>Sistema de Deteccion de Duplicados <br/>"+"FECHA: "+DateTime.Now.ToString("yyyy'-'MM'-'dd HH':'mm")+"</div></td></tr><tr height='20'>"+
                "<td width='163'><span class='Estilo2'></span></td><td width='54'><span class='Estilo2'></span></td><td width='157'>"+
                "<span class='Estilo2'></span></td><td width='157'><span class='Estilo2'></span></td><td width='159'><span class='Estilo2'></span></td>"+
                "</tr><tr height='20'><td><span class='Estilo2'><strong>Sistema</strong>:</span></td><td colspan='4'>Sistema de Deteccion de Duplicados</td></tr><tr height='20'><td>&nbsp;</td>"+
                "<td colspan='4'>&nbsp;</td></tr><tr height='20'><td><span class='Estilo2'><strong>Estado del Proceso: </strong></span></td><td colspan='4'><span class='Estilo2'>Finalizado</span></td></tr>"+
                "<tr height='20'><td><span class='Estilo2'></span></td><td><span class='Estilo2'></span></td><td><span class='Estilo2'></span></td><td><span class='Estilo2'></span></td><td><span class='Estilo2'></span></td></tr><tr height='20'><td><span class='Estilo1'>Total Documentos Pendientes: </span></td><td colspan='4'><span class='Estilo2'>"+this.files+"</span></td></tr>"+
                "<tr height='20'><td><span class='Estilo2'></span></td><td><span class='Estilo2'></span></td><td><span class='Estilo2'></span></td><td><span class='Estilo2'></span></td><td><span class='Estilo2'></span></td></tr><tr height='20'><td><span class='Estilo1'>Total Documentos Procesados:</span></td><td colspan='4'><span class='Estilo2'>"+this.documentsOk+"</span></td></tr>"+
                "<tr height='20'><td><span class='Estilo2'></span></td><td><span class='Estilo2'></span></td><td><span class='Estilo2'></span></td><td><span class='Estilo2'></span></td><td><span class='Estilo2'></span></td></tr><tr height='20'><td><span class='Estilo1'>Total Documentos No Procesados:</span></td><td colspan='4'><span class='Estilo2'>"+this.documentsNoOk+"</span></td></tr>"+
                "<tr height='20'><td>&nbsp;</td><td></td><td></td><td></td><td></td></tr><tr height='20'><td colspan='5' bgcolor='#003366'>"+
                "<div align='center'><span class='Estilo6'>Breve Descripcion</span></div></td></tr>"+
                "<tr height='20'><td colspan='5'><span class='Estilo2'>El proceso tardo" + DateTime.Now.Subtract(beginTime).ToString() +" tiempo en procesar todos los documentos</span></td></tr><tr height='20'>"+
                "</body></html></body></html>";
        }


        public void sendMessage()
        {
            
            using (var _proxy = new IServicioEmail.ServicioEmailClient("NetTcpBinding_IServicioEmail"))
            {

                IServicioEmail.EmailGeneral _correo = new IServicioEmail.EmailGeneral();
                _correo.FechaCreacion = DateTime.Now;
                _correo.CodSistema = Configuration.systemID;
                _correo.Cuerpo = this.toString();
                _correo.Encabezado = "Resultados del Procesamiento del Sitema de Deteccion de Duplicados";
                for (int i = 0; i < Configuration.emailAccountTo.Length; i++)
                {
                    _correo.Para = Configuration.emailAccountTo[i];
                    _proxy.Agregar(_correo);
                }
            }            
        }
    }
}
